#!/usr/bin/python3
# -*- coding:utf-8 -*-
# __author__ == taoyulong2018@gmail.com
# __time__ == 2023/3/2 8:31
# ===========================================
#       题目名称： 26. 删除有序数组中的重复项
#       题目地址： https://leetcode.cn/problems/remove-duplicates-from-sorted-array/
#       题目描述： https://note.youdao.com/s/LWYgPSzT
# ===========================================


class Solution:
    def removeDuplicates(self, nums):
        if len(nums) < 1:
            return len(nums)
        currentIndex = 1
        while currentIndex < len(nums):
            if nums[currentIndex] == nums[currentIndex - 1]:
                del nums[currentIndex]
            else:
                currentIndex += 1
        return len(nums)


if __name__ == "__main__":
    s = Solution()
    print("nums = [1,1,2] =>", s.removeDuplicates(nums=[1, 1, 2]))  # 2
    print("nums = [0,0,1,1,1,2,2,3,3,4] =>", s.removeDuplicates(nums=[0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))  # 5
